import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

enum FamilyTextColor { white, red, money, points, black }

enum FontFamily { poppins, gilroyBold, unileverShilling }

final Map<int, double> fontSizeMap = {
  10: 10.sp,
  11: 11.sp,
  12: 12.sp,
  13: 13.sp,
  14: 14.sp,
  15: 15.sp,
  16: 16.sp,
  17: 17.sp,
  18: 18.sp,
  19: 19.sp,
  20: 20.sp,
  21: 21.sp,
  22: 22.sp,
  23: 23.sp,
  24: 24.sp,
  25: 25.sp,
  26: 16.sp,
  27: 27.sp,
  28: 28.sp,
  29: 29.sp,
  30: 30.sp,
  31: 31.sp,
  32: 32.sp,
  33: 33.sp,
  34: 34.sp,
  35: 35.sp,
};
final Map<int, FontWeight> fontWeightMap = {
  300: FontWeight.w300,
  400: FontWeight.w400,
  500: FontWeight.w500,
  600: FontWeight.w600,
  700: FontWeight.w700,
  800: FontWeight.w800,
  900: FontWeight.w900,
};

class AppColors {
  static const Color primary = Color(0xFF000000);
  static const Color white = Color(0xFFFFFFFF);
  static const Color black = Color(0xFF222222);
  static const Color red = Color(0xFFD73030);
  static const Color gradientStart1 = Color(0xFF731E3E);
  static const Color gradientEnd1 = Color(0xFF222222);
  static const Color gradientStart2 = Color(0xFF20345A);
  static const Color gradientEnd2 = Color(0xFF222222);
  static const Color gradientStart4 = Color(0xFF66502B); // demo 黄色
  static const Color gradientStart3 = Color(0XFF416658);
  static const Color gradientEnd3 = Color(0xFF222222); // demo 黄色
  // static const Color gradientEnd3 = Color(0xFF222222);
  static const Color shareBtnColor = Color(0XFFD73030);
  //
  static const Color moneyColor = Color(0XFFFFC640);
  //
  static const Color pointsColor = Color(0xFF63B9FF);
  //
  static const Color sheetBgColor = Color(0XFF222222);
  static const Color flowBorderColor = Color(0XFFFFFFFF);

  // input
  static const Color textFieldCursorColor = Color(0XFFFFFFFF);

  // task 状态 背景
  static const Color taskSatusBg = Color(0X30FFCCCC);

  //
  static const Color containerBg = Color(0xFF222222);

  // toast 背景
  static const Color toastBackground = Color(0XC0444444);
}

TextStyle customTextStyle({
  final FamilyTextColor? color = FamilyTextColor.white,
  int? fontSize = 12,
  double? height = 1,
  double? opacity,
  double? fontWeight = 400,
  TextOverflow? overflow,
  FontFamily? fontFamily = FontFamily.poppins,
}) {
  Color textColor;
  switch (color) {
    case FamilyTextColor.white:
      textColor = AppColors.white;
      break;
    case FamilyTextColor.red:
      textColor = AppColors.red;
    case FamilyTextColor.money:
      textColor = AppColors.moneyColor;
    case FamilyTextColor.points:
      textColor = AppColors.pointsColor;
      break;
    case FamilyTextColor.black:
      textColor = AppColors.black;
      break;
    default:
      textColor = AppColors.white;
  }

  if (opacity != null) {
    textColor = textColor.withAlpha((255 * opacity).floor());
  }

  String family;

  switch (fontFamily) {
    case FontFamily.gilroyBold:
      family = 'Gilroy-Bold';
      break;
    case FontFamily.poppins:
      family = 'Poppins';
      break;
    case FontFamily.unileverShilling:
      family = 'Unilever Shilling';
      break;
    default:
      family = 'Poppins';
  }

  return TextStyle(
    fontFamily: family,
    fontSize: fontSizeMap[fontSize],
    color: textColor,
    height: height,
    overflow: overflow ?? TextOverflow.visible,
    fontWeight: fontWeightMap[fontWeight],
  );
}

InputDecoration customInputDecoration({extendConfig}) {
  return InputDecoration(
    // hintText: "Username",
    fillColor: AppColors.containerBg,
    focusColor: AppColors.white,
    hintStyle: TextStyle(color: Colors.white),
    enabledBorder: OutlineInputBorder(
      borderRadius: BorderRadius.circular(10.0),
      borderSide: BorderSide(
        //   color: Colors.transparent, // 边框颜色
        color: Colors.white, // 边框颜色
        width: 2.0, // 边框宽度
      ),
    ),
    focusedBorder: OutlineInputBorder(
      borderRadius: BorderRadius.circular(10.0),
      borderSide: BorderSide(
        color: AppColors.white, // 聚焦时边框颜色
        width: 1.r, // 边框宽度
      ),
    ),
  );
}
